package com.qilu.careprogram.service.impl;

import com.qilu.careprogram.dao.ReviewDao;
import com.qilu.careprogram.pojo.dto.ReviewInfoDTO;
import com.qilu.careprogram.pojo.ReviewInfo;
import com.qilu.careprogram.service.ReviewService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ReviewServiceImpl implements ReviewService {

    @Resource
    private ReviewDao reviewDao;

    @Override
    public void addReviewInfo(ReviewInfoDTO reviewInfoDTO) {
        ReviewInfo reviewInfo = new ReviewInfo();
        reviewInfo.setHospitalNumber(reviewInfoDTO.getHospitalNumber());
        reviewInfo.setProjectName(reviewInfoDTO.getProjectName());
        reviewInfo.setReviewTime(reviewInfoDTO.getReviewTime());
        reviewInfo.setAppointmentTime(reviewInfoDTO.getAppointmentTime());
        reviewInfo.setIsEmpty(reviewInfoDTO.getIsEmpty());
        reviewInfo.setImages(reviewInfoDTO.getImages());

        reviewDao.insertReviewInfo(reviewInfo);
    }

    @Override
    public List<ReviewInfo> getReviewInfo(String hospitalNumber) {
        return reviewDao.selectReviewInfoByHospitalNumber(hospitalNumber);
    }

    @Override
    public void updateReviewInfo(ReviewInfoDTO reviewInfoDTO) {
        ReviewInfo reviewInfo = new ReviewInfo();
        reviewInfo.setId(reviewInfoDTO.getId());
        reviewInfo.setProjectName(reviewInfoDTO.getProjectName());
        reviewInfo.setReviewTime(reviewInfoDTO.getReviewTime());
        reviewInfo.setAppointmentTime(reviewInfoDTO.getAppointmentTime());
        reviewInfo.setIsEmpty(reviewInfoDTO.getIsEmpty());
        reviewInfo.setImages(reviewInfoDTO.getImages());

        reviewDao.updateReviewInfo(reviewInfo);
    }
}